package cn.aigoubuy.dao;

import cn.aigoubuy.domain.Order;
import cn.aigoubuy.domain.OrderItem;
import cn.aigoubuy.domain.User;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

/**
* 订单dao接口
*/
public interface OrderDao {
    /**
    * 保存订单
    * @param connection
    * @param order
    * @throws SQLException
    */
    void saveOrder(Connection connection, Order order) throws SQLException;

    /**
     * 保存订单详情
     * @param connection
     * @param item
     * @throws SQLException
     */
    void saveOrderItem(Connection connection, OrderItem item) throws SQLException;

    /**
     * 通过用户查询订单记录数
     * @param user 指定用户
     * @return
     * @throws SQLException
     */
    int findTotalRecordByUid(User user) throws SQLException;
    /**
     * 查询用户订单分页数据
     * @param user 指定用户
     * @param startIndex 开始索引
     * @param pageSize 每页显示个数
     * @return
     * @throws Exception
     */
    List<Order> findAllByUid(User user, int startIndex, int pageSize) throws Exception;

    /**
     * 通过oid查询详情
     * @param oid
     * @return
     * @throws Exception
     */
    Order findByOid(String oid) throws Exception;

    /**
     * 更新订单
     * @param order
     * @throws Exception
     */
    void update(Order order) throws Exception;
}